<template>
  <div class="login paga-data">
    <div class="login-bg"></div>
    <div class="login-form">
      <div class="login-content">
        <h4 class="title">一站式信息服务系统</h4>
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="demo-ruleForm">
          <el-form-item label="" prop="usercode">
            <el-input v-model="ruleForm.usercode" placeholder="请输入账号" @keyup.enter.native="submitForm">
              <i slot="prefix" class="el-input__icon el-icon-user"></i>
            </el-input>
          </el-form-item>
          <el-form-item label="" prop="password">
            <el-input v-model="ruleForm.password" placeholder="请输入密码" type="password" @keyup.enter.native="submitForm">
              <i slot="prefix" class="el-input__icon el-icon-lock"></i>
            </el-input>
          </el-form-item>
          <el-form-item class="login-item">
            <el-button type="primary" icon="el-icon-right" @click="submitForm()" :loading="loading">登录</el-button>
            <!-- <el-button @click="resetForm('ruleForm')">重置</el-button> -->
          </el-form-item>
        </el-form>
      </div>
    </div>
    <!-- <div id="particles" class="particles"></div> -->
  </div>
</template>
<script>
export default {
  components: {

  },
  data() {
    return {
      loading: false,
      ruleForm: {
        usercode: '',
        password: '',
      },
      rules: {
        usercode: [
          { required: true, message: '请输入账号', trigger: 'submit' },
        ],
        password: [
          { required: true, message: '请输入密码', trigger: 'submit' },
        ],
      },
      showEarth: false,
    };
  },
  mounted() {
    // this.$root.userInfo={};
    particlesJS('particles',
      {
        "particles": {
          "number": {
            "value": 40,
            "density": {
              "enable": true,
              "value_area": 800
            }
          },
          "color": {
            "value": "#50B6C1"
          },
          "shape": {
            "type": "circle",
            "stroke": {
              "width": 0,
              "color": "#50B6C1"
            },
            "polygon": {
              "nb_sides": 5
            },
            "image": {
              "src": "img/github.svg",
              "width": 100,
              "height": 100
            }
          },
          "opacity": {
            "value": 0.5,
            "random": false,
            "anim": {
              "enable": false,
              "speed": 1,
              "opacity_min": 0.1,
              "sync": false
            }
          },
          "size": {
            "value": 5,
            "random": true,
            "anim": {
              "enable": false,
              "speed": 100,
              "size_min": 0.1,
              "sync": false
            }
          },
          "line_linked": {
            "enable": true,
            "distance": 150,
            "color": "#50B6C1",
            "opacity": 0.4,
            "width": 1
          },
          "move": {
            "enable": true,
            "speed": 3,
            "direction": "none",
            "random": false,
            "straight": false,
            "out_mode": "out",
            "attract": {
              "enable": false,
              "rotateX": 600,
              "rotateY": 1200
            }
          }
        },
        "interactivity": {
          "detect_on": "canvas",
          "events": {
            "onhover": {
              "enable": false,
              "mode": "repulse"
            },
            "onclick": {
              "enable": true,
              "mode": "push"
            },
            "resize": true
          },
          "modes": {
            "grab": {
              "distance": 400,
              "line_linked": {
                "opacity": 1
              }
            },
            "bubble": {
              "distance": 400,
              "size": 40,
              "duration": 2,
              "opacity": 8,
              "speed": 3
            },
            "repulse": {
              "distance": 200
            },
            "push": {
              "particles_nb": 4
            },
            "remove": {
              "particles_nb": 2
            }
          }
        },
        "retina_detect": true,
        "config_demo": {
          "hide_card": false,
          "background_color": "#50B6C1",
          "background_image": "",
          "background_position": "50% 50%",
          "background_repeat": "no-repeat",
          "background_size": "cover"
        }
      }
    );
  },
  methods: {
    submitForm() {
      this.$refs["ruleForm"].validate((valid) => {
        if (valid) {
          let params = this.ruleForm;
          this.loading = true;
          setTimeout(() => {
            this.loading = false;
            if (params.usercode == "admin" && params.password == "bh-61290208" || this.configs.NODE_ENV == "dev") {
              let userInfo = {
                token: this.func.uuid(),
              }
              this.func.setSession("userInfo", userInfo);
              this.$router.replace({ path: '/monitor' });
              // this.func.message("登录成功", "success");
            } else {
              this.func.message("error", "账号或者密码错误");
            }
          }, 200)

          // this.https("post", "/api/Account/Login", params).then(res => {
          //   this.loading = false;
          //   if (res.state && res.code == 200) {
          //     let userInfo = res.data;
          //     userInfo.token = userInfo.token_type + " " + userInfo.access_token;
          //     this.$root.userInfo = userInfo;
          //     this.func.setSession("userInfo", userInfo);
          //     this.func.message("登录成功", "success");
          //     this.$router.replace({ path: '/home/overview' });
          //     this.$root.getUserBaseInfo();
          //   } else {
          //     this.func.message(res.msg);
          //   }
          // }).catch(() => {
          //   this.loading = false;
          // })
        } else {
          return false;
        }
      });
    },
    resetForm() {
      this.$refs["ruleForm"].resetFields();
    },
  },
}
</script>
<style lang="scss">
.login .el-form-item {
  margin-bottom: 25px !important;

  .el-form-item__label {
    color: #fff;
  }

  .el-input__inner {
    background-color: rgba($color: #000000, $alpha: 0.2);
    color: #fff;
    height: 40px;
    border-color: #42b8ff;
    background-color: rgba($color: #126db1, $alpha: 0.2);
    padding-left: 40px;

    &::placeholder {
      color: #fff;
    }

    &:focus::placeholder {
      color: #176ea3;
    }
  }

  .el-input__prefix {
    color: #42b8ff;
    left: 10px;
  }

  .el-input__icon {
    line-height: 40px;
    font-size: 20px;
  }
}
</style>
<style lang="scss" scoped>
.login {
  position: relative;
  height: 100vh;
  width: 100vw;
  background-image: url("../../assets/images/login_bg.jpg");
  background-size: 100% 100%;
  overflow: hidden;
  background-color: #141e3f;

  .login-form {
    position: absolute;
    left: 50%;
    width: 420px;
    top: 50%;
    z-index: 10;
    transform: translate(-50%, -60%);

    .system-name {
      text-align: center;
      padding: 0 50px;
      margin-bottom: 30px;

      img {
        width: 100%;
      }
    }

    .login-content {
      background-image: url("../../assets/images/login_content_bg.png");
      background-size: 100% 100%;
      padding: 50px;
      height: auto;

      .title {
        text-align: center;
        font-size: 20px;
        color: #42b8ff;
        margin-bottom: 40px;
        font-weight: bold;
      }

      .login-item {
        text-align: center;
        margin-top: 40px;
        margin-bottom: 0 !important;

        .el-button {
          display: block;
          height: 40px;
          font-size: 15px;
          width: 100%;
        }
      }
    }
  }

  .login-bg {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 2;
    background-color: rgba($color: #000000, $alpha: 0.2);
    // background-image: url("../../assets/images/login_bg2.png");
    // background-repeat: no-repeat;
    // background-position: 5% 70%;
    // background-size: auto 90%;
  }

  .canvas {
    position: absolute;
    left: 0%;
    z-index: 3;
  }

  .gl-chart {
    position: absolute;
    left: 8%;
    top: 0;
    bottom: 0;
    width: 40%;
    z-index: 2;
  }
}

.bg-bubbles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.bg-bubbles li,
.bg-bubbles ol {
  position: absolute;
  list-style: none;
  display: block;
  width: 40px;
  height: 40px;
  background-color: rgba(255, 255, 255, 0.15);
  bottom: -160px;
  -webkit-animation: square 25s infinite;
  animation: square 25s infinite;
  -webkit-transition-timing-function: linear;
  transition-timing-function: linear;
}

.bg-bubbles ol {
  padding: 0 !important;
}

.bg-bubbles ol:nth-child(11) {
  left: 10%;
  top: 10%;
  width: 20px;
  height: 20px;
}

.bg-bubbles ol:nth-child(12) {
  left: 20%;
  top: 40%;
  width: 60px;
  height: 60px;
}

.bg-bubbles ol:nth-child(13) {
  left: 65%;
  top: 30%;

  width: 100px;
  height: 60px;
}

.bg-bubbles ol:nth-child(14) {
  left: 70%;
  top: 30%;
  width: 100px;
  height: 150px;
}

.bg-bubbles ol:nth-child(15) {
  left: 50%;
  top: 70%;
  width: 40px;
  height: 60px;
}

.bg-bubbles li:nth-child(1) {
  left: 10%;
}

.bg-bubbles li:nth-child(2) {
  left: 20%;
  width: 80px;
  height: 80px;
  -webkit-animation-delay: 2s;
  animation-delay: 2s;
  -webkit-animation-duration: 17s;
  animation-duration: 17s;
}

.bg-bubbles li:nth-child(3) {
  left: 25%;
  -webkit-animation-delay: 4s;
  animation-delay: 4s;
}

.bg-bubbles li:nth-child(4) {
  left: 40%;
  width: 60px;
  height: 60px;
  -webkit-animation-duration: 22s;
  animation-duration: 22s;
  background-color: rgba(255, 255, 255, 0.25);
}

.bg-bubbles li:nth-child(5) {
  left: 70%;
}

.bg-bubbles li:nth-child(6) {
  left: 80%;
  width: 120px;
  height: 120px;
  -webkit-animation-delay: 3s;
  animation-delay: 3s;
  background-color: rgba(255, 255, 255, 0.2);
}

.bg-bubbles li:nth-child(7) {
  left: 32%;
  width: 160px;
  height: 160px;
  -webkit-animation-delay: 7s;
  animation-delay: 7s;
}

.bg-bubbles li:nth-child(8) {
  left: 55%;
  width: 20px;
  height: 20px;
  -webkit-animation-delay: 15s;
  animation-delay: 15s;
  -webkit-animation-duration: 40s;
  animation-duration: 40s;
}

.bg-bubbles li:nth-child(9) {
  left: 25%;
  width: 10px;
  height: 10px;
  -webkit-animation-delay: 2s;
  animation-delay: 2s;
  -webkit-animation-duration: 40s;
  animation-duration: 40s;
  background-color: rgba(255, 255, 255, 0.3);
}

.bg-bubbles li:nth-child(10) {
  left: 90%;
  width: 160px;
  height: 160px;
  -webkit-animation-delay: 11s;
  animation-delay: 11s;
}

@-webkit-keyframes square {
  0% {
    -webkit-transform: translateY(0);
    transform: translateY(0);
  }

  100% {
    -webkit-transform: translateY(-700px) rotate(600deg);
    transform: translateY(-700px) rotate(600deg);
  }
}

@keyframes square {
  0% {
    -webkit-transform: translateY(0);
    transform: translateY(0);
  }

  100% {
    -webkit-transform: translateY(-700px) rotate(600deg);
    transform: translateY(-700px) rotate(600deg);
  }
}
</style>